package gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JTable;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.JButton;

public class LoeschenGUI extends JFrame implements ActionListener {

	private JPanel contentPane;
	private JTextField textField;
	
	private JPanel pnlAuto;
	private JPanel pnlPneu;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					LoeschenGUI frame = new LoeschenGUI();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public LoeschenGUI() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBackground(new Color(0, 102, 255));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblLschen = new JLabel("L\u00F6schen");
		lblLschen.setHorizontalAlignment(SwingConstants.CENTER);
		lblLschen.setFont(new Font("Lucida Grande", Font.PLAIN, 64));
		lblLschen.setBounds(22, 6, 405, 64);
		contentPane.add(lblLschen);
		
		pnlAuto = new JPanel();
		pnlAuto.setBounds(56, 197, 324, 71);
		contentPane.add(pnlAuto);
		pnlAuto.setLayout(new GridLayout(2, 4, 0, 0));
		
		JLabel lblMarkeAuto = new JLabel("Marke");
		pnlAuto.add(lblMarkeAuto);
		
		JLabel lblModellAuto = new JLabel("Modell");
		pnlAuto.add(lblModellAuto);
		
		JLabel lblTypAuto = new JLabel("Typ");
		pnlAuto.add(lblTypAuto);
		
		JLabel lblFarbeAuto = new JLabel("Farbe");
		pnlAuto.add(lblFarbeAuto);
		
		JLabel lblAusgabeMarkeAuto = new JLabel("");
		pnlAuto.add(lblAusgabeMarkeAuto);
		
		JLabel lblAusgabeModellAuto = new JLabel("");
		pnlAuto.add(lblAusgabeModellAuto);
		
		JLabel lblAusgabeTypAuto = new JLabel("");
		pnlAuto.add(lblAusgabeTypAuto);
		
		JLabel lblAusgabeFarbe = new JLabel("");
		pnlAuto.add(lblAusgabeFarbe);
		
		textField = new JTextField();
		textField.setBounds(316, 122, 74, 28);
		contentPane.add(textField);
		textField.setColumns(10);
		
		
		ButtonGroup grp = new ButtonGroup();
		
		JToggleButton tglbtnAuto = new JToggleButton("Auto");
		tglbtnAuto.addActionListener(this);
		tglbtnAuto.setBounds(46, 82, 161, 29);
		contentPane.add(tglbtnAuto);
		
		JToggleButton tglbtnPneu = new JToggleButton("Pneu");
		tglbtnPneu.setBounds(229, 82, 161, 29);
		tglbtnPneu.addActionListener(this);
		contentPane.add(tglbtnPneu);
		
		grp.add(tglbtnAuto);
		grp.add(tglbtnPneu);
		
		
		JLabel lblNewLabel = new JLabel("Bitte Eindeutige Nummer (ID) eingeben:");
		lblNewLabel.setBounds(67, 128, 265, 16);
		contentPane.add(lblNewLabel);
		
		JButton btnSuche = new JButton("Suche");
		btnSuche.setBounds(165, 156, 117, 29);
		contentPane.add(btnSuche);
		
		pnlPneu = new JPanel();
		pnlPneu.setBounds(56, 197, 324, 71);
		contentPane.add(pnlPneu);
		pnlPneu.setLayout(new GridLayout(2, 4, 0, 0));
		
		JLabel lblMarkePneu = new JLabel("Marke");
		pnlPneu.add(lblMarkePneu);
		
		JLabel lblDimensionPneu = new JLabel("Dimension");
		pnlPneu.add(lblDimensionPneu);
		
		JLabel lblAblaufdatumPneu = new JLabel("Ablaufda.");
		pnlPneu.add(lblAblaufdatumPneu);
		
		JLabel lblSommerwinterPneu = new JLabel("Som/Wint");
		pnlPneu.add(lblSommerwinterPneu);
		
		JLabel lblAusgabeMarkePneu = new JLabel("");
		pnlPneu.add(lblAusgabeMarkePneu);
		
		JLabel lblAusgabeDimensionPneu = new JLabel("");
		pnlPneu.add(lblAusgabeDimensionPneu);
		
		JLabel lblAusgabeAblaufdatumPneu = new JLabel("");
		pnlPneu.add(lblAusgabeAblaufdatumPneu);
		
		JLabel lblAusgabeSommerWinterPneu = new JLabel("");
		pnlPneu.add(lblAusgabeSommerWinterPneu);
		
		JButton button_zurueck = new JButton("<--");
		button_zurueck.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new StartGUI().setVisible(true);
				dispose();
			}
		});
		button_zurueck.setBounds(6, 29, 50, 29);
		contentPane.add(button_zurueck);
	}

	@Override
	public void actionPerformed(ActionEvent event) {
		if (event.getActionCommand().equals("Auto")){
			pnlAuto.setVisible(true);
			pnlPneu.setVisible(false);
			
			
		} else if(event.getActionCommand().equals("Pneu"))
		{
			pnlAuto.setVisible(false);
			pnlPneu.setVisible(true);
		}
		
	}
}
